﻿@using SCMS.Resource
@model SCMS.UI.Models.CommitDetailModel

@if (Model.BudgetCommits.Count() > 0)
{
    if (Model.HasProcurement)
    {
        <h4 style="text-align: center;">@Resources.Global_String_Procurement.ToUpper()</h4>  
        <table align="center" class="cardTable" style="min-width: 700px;">
            <tr>
                <th>@Resources.Global_String_Date</th>
                <th>@Resources.Global_String_Amount</th>
                <th>@Resources.Global_String_OR</th>
                <th>@Resources.Global_String_PO</th>
                <th>@Resources.Global_String_RFP</th>
                <th>@Resources.Global_String_ItemName</th>
            </tr>
            @foreach (var item in Model.BudgetCommits)
            {
                if (item.RFPBudgetLineId.HasValue || item.PurchaseOrderItemId.HasValue || item.OrderRequestItemId.HasValue)
                {
                    <tr>
                        <td align="center">
                            @item.DateCommitted.ToString("dd/MM/yyyy")
                        </td>
                        <td align="right">
                            @item.AmountCommitted.ToString("#,##0.00")
                        </td>
                        @if (item.RFPBudgetLineId.HasValue)
                        { 
                            <td>@item.PaymentRequestBudgetLine.PurchaseOrderItem.OrderRequestItem.OrderRequest.RefNumber</td>
                            <td>@item.PaymentRequestBudgetLine.PurchaseOrderItem.PurchaseOrder.RefNumber</td>
                            <td>@item.PaymentRequestBudgetLine.PaymentRequest.RefNumber</td>
                            <td title="@item.PaymentRequestBudgetLine.PurchaseOrderItem.OrderRequestItem.ItemDescription">@item.PaymentRequestBudgetLine.PurchaseOrderItem.OrderRequestItem.Item.Name</td>
                        }
                        else if (item.PurchaseOrderItemId.HasValue)
                        { 
                            <td>@item.PurchaseOrderItem.OrderRequestItem.OrderRequest.RefNumber</td>
                            <td>@item.PurchaseOrderItem.PurchaseOrder.RefNumber</td>
                            <td>&nbsp;</td>
                            <td title="@item.PurchaseOrderItem.OrderRequestItem.ItemDescription">@item.PurchaseOrderItem.OrderRequestItem.Item.Name</td>
                        }
                        else if (item.OrderRequestItemId.HasValue)
                        { 
                            <td>@item.OrderRequestItem.OrderRequest.RefNumber</td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                            <td title="@item.OrderRequestItem.ItemDescription">@item.OrderRequestItem.Item.Name</td>
                        }
                    </tr>
                }
            }
        </table>
    }
    if (Model.HasFinance)
    {
        <h4 style="text-align: center;">@Resources.Global_String_Finance.ToUpper()</h4>  
        <table align="center" class="cardTable" style="min-width: 700px;">
            <tr>
                <th>@Resources.Global_String_Date</th>
                <th>@Resources.Global_String_Amount</th>
                <th>@Resources.Approver_CreateApprover_DocumentType</th>
                <th>@Resources.Report_Documents_DocNo</th>
                <th>@Resources.Global_String_Details</th>
            </tr>
            @foreach (var item in Model.BudgetCommits)
            {
                if (item.RFABudgetLineId.HasValue || item.ExpenseItemId.HasValue || item.SalaryBudgetLineId.HasValue || item.TravelDateId.HasValue || item.TravelExpenseId.HasValue)
                {
                    <tr>
                        <td align="center">
                            @item.DateCommitted.ToString("dd/MM/yyyy")
                        </td>
                        <td align="right">
                            @item.AmountCommitted.ToString("#,##0.00")
                        </td>
                        @if (item.RFABudgetLineId.HasValue)
                        { 
                            <td>@Resources.Global_String_RequestForAdvance</td>
                            <td>@item.AdvanceRequestBudgetLine.AdvanceRequest.RefNumber</td>
                            <td title="@item.AdvanceRequestBudgetLine.AdvanceRequestOption.Description">@item.AdvanceRequestBudgetLine.AdvanceRequestOption.Name</td>
                        }
                        else if (item.ExpenseItemId.HasValue)
                        { 
                            <td>@Resources.Global_String_ExpenseClaim</td>
                            <td>@item.ExpenseItem.ExpenseRequest.RefNumber</td>
                            <td>@item.ExpenseItem.ItemDescription</td>
                        }
                        else if (item.SalaryBudgetLineId.HasValue)
                        { 
                            <td>@Resources.Global_String_SalaryPayment</td>
                            <td>@item.SalaryBudgetline.SalaryRequest.RefNumber</td>
                            <td title="@item.SalaryBudgetline.PayrollItem.Description">@item.SalaryBudgetline.PayrollItem.Name</td>
                        }
                        else if (item.TravelDateId.HasValue)
                        {
                            <td>@Resources.Global_String_TravelAuthorization</td>
                            <td>@item.TravelDate.TravelAuthorization.RefNumber</td>
                            <td title="@Resources.TravelAuthorization_LoadTravelDate_TravelDate: @item.TravelDate.TravalDate.Value">@Resources.Global_String_Destination: @item.TravelDate.Destination</td>
                        }
                        else if (item.TravelExpenseId.HasValue)
                        { 
                            <td>@Resources.Global_String_TravelAuthorization</td>
                            <td>@item.TravelExpense.TravelAuthorization.RefNumber</td>
                            <td>@item.TravelExpense.ExpenseDescription</td>
                        }
                    </tr>
                }
            }
        </table>
    }
    if (!Model.HasFinance && !Model.HasProcurement)
    { 
        <br />
        <center style="font-style: italic; text-align: center;">No details were found!!</center>
    }
}

